package com.example.yyjgit.tool;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

@Component//依赖注入框架
public class RedisTool {
    public Jedis getJedis(){
        Jedis jedis=null;
        try{
            jedis=new Jedis("49.235.89.147",6379);
            jedis.auth("yyj1832357965");
            jedis.select(0);
            System.out.println("链接成功");
        }catch (Exception e){
            System.out.println("链接失败");
        }finally {
            if (jedis != null) {
                try {
                    jedis.close();
                }catch (Exception e){
                    System.out.println("关闭失败"+e.getMessage());
                }
            }
        }
        return jedis;
    }


}
